#include "TcpServer.hpp"
#include "Http.hpp"
#include "daemon.hpp"

// ./tcpserver 8888
int main(int argc, char *argv[])
{
    if (argc != 2)
    {
        std::cerr << "Usage: " << argv[0] << " local-port" << std::endl;
        exit(0);
    }
    uint16_t port = std::stoi(argv[1]);

    HttpServer hserver;
    
    service_t service = std::bind(&HttpServer::HandlerHttpRequest, &hserver, std::placeholders::_1);

    Deamon(false, false); // 守护进程
    std::shared_ptr<TcpServer> tsvr = std::make_shared<TcpServer>(service, port);
    tsvr->Loop();

    return 0;
}
